package com.persons.springbootproject.controller;

import com.persons.springbootproject.entity.Emp;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @projectName: springboot-project
 * @package: com.persons.springbootproject.controller
 * @className: EmpController
 * @author: Navid
 * @description: TODO
 * @date: 2021/10/20 20:50
 * @version: 1.0
 */
@RestController
public class EmpController {

    @GetMapping("/info")
    public Object info() {
        Emp emp = new Emp(1L, "小强");
        emp.setAge(20);
        emp.setTitle("班长");
        emp.setWork("打杂");
        return emp;
    }

    @GetMapping("/infoList")
    public Object infoList() {
        List<Emp> empList = new ArrayList<>(2);
        for (Long i = 0L; i < 3L; i++) {
            Emp emp = new Emp(i, "小强-" + i);
            emp.setAge(20);
            emp.setTitle(i + "班班长");
            emp.setWork("给" + i + "打杂");
            empList.add(emp);
        }
        return empList;
    }
}
